{include file="pub:header"/}
</head>
<body>

<div class="subnav">
    <div class="content_menu ib_a blue line_x">
        <a href="javascript:;"><span class="pagetitle">【备份数据库】</span></a>
        <a href="{:url('database/index',array('type'=>'export'))}"><em>备份数据库</em></a>
        <span>|</span><a href="{:url('database/index',array('type'=>'import'))}" class="on"><em>下载备份数据</em></a>

    </div>
</div>

<div class="pad_lr_10">
    <div class="J_tablelist table_list">

        <table width="100%" cellspacing="0">

            <thead>
            <tr>
                    <th>备份名称</th>
                    <th>卷数</th>
                    <th>压缩</th>
                    <th>数据大小</th>
                    <th>备份时间</th>
                    <th>状态</th>
                    <th>操作</th>
            </tr>
            </thead>

    	    <tbody>

                {volist name="list" id="data"}
                    <tr>
                        <td align="center">{$data.time|date='Ymd-His'}</td>
                        <td align="center">{$data.part}</td>
                        <td align="center">{$data.compress}</td>
                        <td align="center">{$data.size|format_bytes}</td>
                        <td align="center">{$key}</td>
                        <td align="center">-</td>
                        <td class="action" align="center">
                            【<a class="db-import" href="{:url('import?time='.$data['time'])}" onclick="javascript:return confirm('是否还原为该备份数据？');">还原</a>】
							【<a href="{$data.filename}" target="_blank">下载</a>】
                            【<a href="{:url('del?time='.$data['time'])}" onclick="javascript:return confirm('是否删除备份数据？');">删除</a>】
                        </td>
                    </tr>
                {/volist}

            </tbody>
        </table>
    </div>


</div>

<script type="text/javascript">
        $(".db-import").click(function(){
            var self = this, status = ".";
            $.get(self.href, success, "json");
            window.onbeforeunload = function(){ return "正在还原数据库，请不要关闭！" }
            return false;

            function success(data){
                if(data.code){
                    if(data.data.gz){
                        data.info += status;
                        if(status.length === 5){
                            status = ".";
                        } else {
                            status += ".";
                        }
                    }
                    $(self).parent().prev().text(data.msg);
                    if(data.data.part){
                        $.get(self.href,
                            {"part" : data.data.part, "start" : data.data.start},
                            success,
                            "json"
                        );
                    }  else {
                        window.onbeforeunload = function(){ return null; }
                    }
                } else {
                    alert(data.msg);
                }
            }
        });
</script>
{include file="pub:footer" /}
